<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/WEB-INF/jsp/importHead.jsp"%>
<%@ include file="/WEB-INF/jsp/importCommonCss.jsp"%>
<link rel="stylesheet" type="text/css" href="${basePath }/css/index-old.css" />
<style>
body.met-navfixed {
	margin: 0 auto;
	padding: 0;
	height: 100%;
	padding-top: 65px;
	min-height: 595px;
}

html {
	margin: 0 auto;
	padding: 0;
	height: 100%;
	min-height: 595px;
	position: relative;
}

html, body {
	margin: 0px;
	height: 100%;
}

body.met-navfixed>section.notice_list_met_11_1 {
	visibility: inherit;
	opacity: 1;
	transform: matrix(1, 0, 0, 1, 0, 0);
	background-color: #F5F5F5;
}

body.met-navfixed>section.notice_list_met_11_1 div.container.notice {
	height: auto;
	line-height: normal;
}

div.form-group>label.form-control-label {
	height: auto;
	line-height: normal;
}

footer.foot_info_met_16_1 {
	background-color: #F5F5F5;
	width: 100%;
}

.red {
	color: red;
}

form.form-horizontal button.btn{
    padding-left: 1.5em;
    padding-right: 1.5em;
    border-radius: 5px;
}

#errorMessageContent label.form-control-label {
    height: 2.573rem;
}
</style>

</head>

<body class="met-navfixed">
	<%@ include file="/WEB-INF/jsp/otherUser/commonHeader.jsp"%>
	
	<section class="notice_list_met_11_1 text-xs-left" m-id="4">
	<div class="container notice clearfix" style="min-height: 532px; min-width: 600px;padding: 20px 130px 40px 130px;">
			<div class="container-fluid" style="border-bottom: 1px #dcdcdc dashed;padding-bottom: 20px;">
				<h1><i class="icon wb-search"></i>找回密码</h1>
				<c:choose>
				<c:when test="${function eq 'DX'}">
					<p>已将验证码发送到您手机${contactNum }，请注意查收。</p>
				</c:when>
				<c:when test="${function eq 'YX'}">
					<p>已将验证码发送到您邮箱${contactNum }，请注意查收。</p>
				</c:when>
				<c:otherwise>
					<p>如果您在登录本系统时提示密码错误而无法登陆时，请填写我们的密码找回申请，找回您的登陆密码</p>
				</c:otherwise>
				</c:choose>
			</div>
			
			<div class="container-fluid" style="border-bottom: 1px #dcdcdc dashed;padding-top: 50px;padding-bottom: 50px;">
				<form action="${basePath }/changePasswordResult" method="post" id="changeForm" class="form-horizontal container">
					<input type="hidden" name="function" value="${function }">
					<input type="hidden" name="uuid" value="${uuid }">
					<div class="container-fluid form-group">
						<label class="col-xs-3 form-control-label">
							用户名：
						</label>
						<div class="col-xs-9">
							${userName }
						</div>
					</div>
					
					<div class="container-fluid form-group">
						<label class="col-xs-3 form-control-label">
							新密码：
						</label>
						<div class="col-xs-4">
							<input  type="password" name="loginPwd" class="form-control" maxlength="20" />
						</div>
					</div>
					
					<div class="container-fluid form-group">
						<label class="col-xs-3 form-control-label">
							确认密码：
						</label>
						<div class="col-xs-4">
							<input type="password" name="reLoginPwd" class="form-control" maxlength="20" />
						</div>
					</div>
					
					<div class="container-fluid form-group">
						<label class="col-xs-3 form-control-label">
							验证码：
						</label>
						<div class="col-xs-4">
							<input type="text" name="yzm" class="form-control" maxlength="20" />
						</div>
						<div class="col-xs-4">
							<button class="btn btn-primary" id="retrieveBtn" type="button" style="padding-left: 41px;padding-right: 41px;">
								重新获取
							</button>
						</div>
					</div>
					
					<div class="container-fluid form-group">
					</div>
					
					<div class="form-group text-xs-center">
						<input class="btn btn-primary" id="submitBtn" type="button" style="padding-left: 41px;padding-right: 41px;" value="下一步" name="action" />
					</div>
				</form>
				<div class="col-xs-12">
					<div class="form-horizontal container" id="errorMessageContent2">
						<div class="container-fluid form-group">
							<label class="form-control-label red" id="errorMsg">
								${ErrorCode }
							</label>
						</div>
					</div>
				</div>
			</div>
			
	</div>
	<%@ include file="/WEB-INF/jsp/importFooter.jsp"%>
	<%@ include file="/WEB-INF/jsp/importCommonJS.jsp"%>
	<%@ include file="/WEB-INF/jsp/manage/importCommonJS.jsp"%>
	<script type="text/javascript" src="${basePath}/js/layer/layer.js"></script>
	<script>
		var maxTime = 60;
		var tempMaxTime = maxTime;
		
		$(function(){
			$("#retrieveBtn").bind("click",function(){
				$.ajax({
					url: "${basePath }/retrieve",
					type: "post",
					data: {uuid: "${uuid}",type: "${function}"},
					dataType: "text",
					success: function(data){
						if(data == "success"){
							layer.msg("已将验证码发送到邮箱/手机，请注意查收。", {
								time: 2000,
							    icon: 1,
							    skin: 'layer-ext-moon'
							});
							
							$("#retrieveBtn").html("激活("+maxTime+")秒");
							$("#retrieveBtn").attr("disabled","disabled");
							
							var temp = setInterval(function(){
								if(tempMaxTime-- > 0){
									$("#retrieveBtn").html("激活("+tempMaxTime+")秒");
									$("#retrieveBtn").attr("disabled","disabled");
								}
								else{
									$("#retrieveBtn").html("激活");
									clearInterval(temp);
									tempMaxTime = maxTime;
									$("#retrieveBtn").removeAttr("disabled");
								}
							},'1000');
						}
						else if(data == "TP_ER"){
							showErrorMessage("验证方式不正确，请重试");
						}
						else if(data == "UK_ER"){
							showErrorMessage("发送验证码失败，请稍后重试");
						}
						else{
							showErrorMessage("连接服务器发生未知错误");
						}
					},
					error: function(){
						showErrorMessage("连接服务器发生未知错误");
					},
					timeout: function(){
						showErrorMessage("连接服务器超时，请检查网络");
					}
				});
			});
			
			$("#submitBtn").bind("click",function(){
				var loginPwd = $("#changeForm")[0].loginPwd.value;
				var loginPwdStr = loginPwd.replace(/(^\s+)|(\s+$)/g,'');
				if(loginPwdStr.length == 0){
					showErrorMessage("请输入新密码");
					return false;
				}
				
				var reLoginPwd = $("#changeForm")[0].reLoginPwd.value;
				var reLoginPwdStr = reLoginPwd.replace(/(^\s+)|(\s+$)/g,'');
				if(loginPwdStr !== reLoginPwdStr){
					showErrorMessage("请确认两次输入的密码一致");
					return false;
				}
				
				var yzm = $("#changeForm")[0].yzm.value;
				var yzmStr = yzm.replace(/(^\s+)|(\s+$)/g,'');
				if(loginPwdStr.length == 0){
					showErrorMessage("请确认验证码");
					return false;
				}
				
				$("#changeForm")[0].submit();
			});
			
			$("#registerForm input").bind("focus",function(){
				$("#errorMessageContent2").hide();
			});
		});
		
		var showErrorMessage = function(text){
			$("#errorMsg").text(text);
			$("#errorMessageContent2").show();

			var timeout = setTimeout(function() {
				$("#errorMessageContent2").hide();
			}, 5000);
		}
	</script>
</body>
</html>
